#!/bin/bash
prefix=../../output/arm_linux
host=arm-linux
build=i386-linux
tmp=tmp123456

cd libs &&
tar -xvzf SDL_ttf-2.0.9.tar.gz &&
cd SDL_ttf-2.0.9 &&
./configure --prefix=$PWD/$prefix --host=$host --includedir="$PWD/$prefix/include"  CFLAGS="-I$PWD/$prefix/include" LDFLAGS="-L$PWD/$prefix/lib -lfreetype -liconv -lts -lSDL" &&
make clean && make && make install 
#cd .. && rm SDL_ttf-2.0.9 -rf 


exit 1

#cd libs &&
#./tar "./*.gz" "." &&
#./tar "./*.bz2" "." &&

mkdir ../$tmp &&
cp libs/tslib-1.4.tar.gz ../$tmp/ &&
cd ../$tmp &&
tar -xvzf tslib-1.4.tar.gz &&
cd tslib &&
./autogen.sh &&
./configure --host=$host --prefix=../../SDL/output/arm_linux ac_cv_func_malloc_0_nonnull=yes &&
make clean && make && make install &&
cd ../../ &&
rm $tmp -rf &&
cd SDL/libs/ && rm tslib -rf &&
#sed -i -e '1,5s/# module_raw input/module_raw input/' SDL/output/arm_linux/etc/ts.conf  &&


tar -xvzf libiconv-1.13.1.tar.gz &&
cd libiconv-1.13.1 &&
./configure --prefix=$PWD/$prefix --host=$host  &&
make clean && make && make install &&
cd .. && rm libiconv-1.13.1 -rf &&

tar -xvzf SDL-1.2.14.tar.gz &&
cd SDL-1.2.14 &&
./configure --prefix=$PWD/$prefix --disable-video-nanox --disable-video-qtopia --disable-video-photon --disable-video-ggi --disable-video-svga --disable-video-aalib --disable-video-dummy --disable-video-dga --disable-arts --disable-esd --disable-alsa --disable-video-x11 --disable-nasm --disable-joystick --enable-input-tslib --enable-video-fbcon --host=$host --build=i386 &&
make clean && make && make install &&

cd test &&
NM=arm-linux-nm LD=arm-linux-ld CC=arm-linux-gcc CXX=arm-linux-g++ AR=arm-linux-ar ./configure --host=$host --prefix=$PWD/../$prefix &&
sed -i -e '8,13s/testgl$(EXE) testhread/testhread/' Makefile &&
sed -i -e '8,13s/testjoystick$(EXE) testkeys/testkeys/' Makefile &&
make clean && make &&
cp graywin loopwave testalpha testbitmap testblitspeed testcdrom testcursor testdyngl testerror testfile testgamma testhread testiconv testkeys testloadso testlock testoverlay testoverlay2 testpalette testplatform testsem testsprite testtimer testver testvidinfo testwin threadwin torturethread  $PWD/../$prefix/bin -dup &&
cd ../.. && rm SDL-1.2.14 -rf && 

tar -xvzf freetype-2.3.11.tar.gz &&
cd freetype-2.3.11 &&
./configure --prefix=$PWD/$prefix --host=$host  &&
make clean && make && make install &&
cd .. && rm freetype-2.3.11 -rf &&

tar -xvzf jpegsrc.v6b.tar.gz &&
cd jpeg-6b &&
mkdir -p $prefix/man/man1 &&
./configure --prefix=$PWD/$prefix --host=$host  --enable-shared --enable-static &&
sed -i -e '8,75s/CC= gcc/CC= arm-linux-gcc/' Makefile &&
sed -i -e '8,75s/AR= ar rc/AR= arm-linux-ar rc/' Makefile &&
sed -i -e '8,75s/AR2= ranlib/AR2= arm-linux-ranlib/' Makefile &&
make clean && make && make install &&
cd .. && rm jpeg-6b -rf &&


tar -xvjf libpng-1.2.19.tar.bz2 &&
cd libpng-1.2.19 &&
./configure --prefix=$PWD/$prefix --host=$host  --enable-shared --enable-static &&
make clean && make && make install &&
cd .. && rm libpng-1.2.19 -rf &&


tar -xvzf libmad-0.15.1b.tar.gz &&
cd libmad-0.15.1b &&
./configure --prefix=$PWD/$prefix --host=$host  &&
sed -i -e '128,130s/-fforce-mem//' Makefile &&
make clean && make && make install &&
cd .. && rm libmad-0.15.1b -rf &&


tar -xvzf libid3tag-0.15.1b.tar.gz &&
cd libid3tag-0.15.1b &&
./configure --prefix=$PWD/$prefix --host=$host  &&
make clean && make && make install &&
cd .. && rm libid3tag-0.15.1b -rf &&


tar -xvzf zlib-1.2.3.tar.gz &&
cd zlib-1.2.3 &&
./configure --prefix=$PWD/$prefix --shared &&
sed -i -e '15,40s/CC=gcc/CC=arm-linux-gcc/' Makefile &&
sed -i -e '15,40s/LDSHARED=gcc/LDSHARED=arm-linux-gcc/' Makefile &&
sed -i -e '15,40s/CPP=gcc -E/CPP=arm-linux-gcc -E/' Makefile &&
sed -i -e '15,40s/AR=ar rc/AR=arm-linux-ar rc/' Makefile &&
sed -i -e '15,40s/RANLIB=ranlib/RANLIB=arm-linux-ranlib/' Makefile &&
make clean && make && make install &&
cd .. && rm zlib-1.2.3 -rf &&


tar -xvzf madplay-0.15.2b.tar.gz &&
cd madplay-0.15.2b &&
./configure --prefix=$PWD/$prefix --host=$host CFLAGS="-I$PWD/$prefix/include" LDFLAGS="-L$PWD/$prefix/lib -lmad -lid3tag" &&
make clean && make && make install &&
cd .. && rm madplay-0.15.2b -rf 

exit 1

tar -xvzf SDL_ttf-2.0.9.tar.gz &&
cd SDL_ttf-2.0.9 &&
./configure --prefix=$PWD/$prefix --host=$host  CFLAGS="-I$PWD/$prefix/include" LDFLAGS="-L$PWD/$prefix/lib -lSDL -lfreetype -liconv" &&
make clean && make && make install &&
cd .. && rm SDL_ttf-2.0.9 -rf &&


tar -xvzf SDL_image-1.2.8.tar.gz &&
cd SDL_image-1.2.8 &&
./configure --prefix=$PWD/$prefix --host=$host  CFLAGS="-I$PWD/$prefix/include" LDFLAGS="-L$PWD/$prefix/lib -lSDL -ljpeg -lpng12" &&
make clean && make && make install &&
cd .. && rm SDL_image-1.2.8 -rf &&


tar -xvzf SDL_mixer-1.2.9.tar.gz &&
cd SDL_mixer-1.2.9 &&
./configure --prefix=$PWD/$prefix --host=$host  --enable-music-mp3-mad-gpl --enable-music-mp3=no CFLAGS="-I$PWD/$prefix/include" LDFLAGS="-L$PWD/$prefix/lib -lSDL -lmad -lid3tag" && 
make clean && make && make install &&
cd .. && rm SDL_mixer-1.2.9 -rf 



